package com.itheima.dao.Impl;

import cn.hutool.core.io.IoUtil;
import com.itheima.dao.Userdao;
import org.springframework.stereotype.Component;

import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

@Component
public class UserdaoImpl implements Userdao {

    // 加载用户数据，返回String类型(初始)数据集合
    public ArrayList<String> findUser(){
        //1.加载并读取文件
        InputStream in = this.getClass().getClassLoader().getResourceAsStream("user.txt");
        ArrayList<String> lines = IoUtil.readLines(in, StandardCharsets.UTF_8, new ArrayList<>());
        return lines;
    }

}
